package com.gzsolar.common.controller;

import Interceptor.LoginInterceptor;

import com.gzsolar.common.model.BiUser;
import com.gzsolar.common.service.BiUserService;
import com.gzsolar.common.validator.BiUserValidator;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;

public class BiUserController extends Controller {
	
	static BiUserService biUserService = new BiUserService();
	
	public void index() {
		setAttr("UserPage", biUserService.paginate(getParaToInt(0, 1), 5));
		render("user.html");
	}
	
	public void add(){
		
	}
	
	@Before(BiUserValidator.class)
	public void save() {
		getModel(BiUser.class,"bi_user").save();
		redirect("/User");
	}
	
	public void edit() {
		setAttr("bi_user", biUserService.findById(getParaToInt()));
	}
	

	@Before(BiUserValidator.class)
	public void update() {
		getModel(BiUser.class,"bi_user").update();
		redirect("/User");
	}
	
	public void delete() {
		biUserService.deleteById(getParaToInt());
		redirect("/User");
	}
	
}
